var waptrun = navigator.userAgent.match(/iPad|iPhone|iPod|Android|Linux/i) != null;
var urlweb = window.location.href;
$(function(){
    if(waptrun && urlweb.match(/news/i)==null){
        urlweb = urlweb.replace(/www.xiaomidj.com/, "m.xiaomidj.com");
        window.location.href=urlweb;
    }
});
var fmpObj, baseDomain = window.location.host,
durl = "dj",
dhtml = ".html",
form_run = "yes";
if ($(document).ready(function() {
    $("#DTab ul").click(function() {
        switch ($(this).index()) {
        case 0:
            mp.datalist(0, 1);
            break;
        case 1:
            mp.datalist(1, 1, did);
            break;
        case 2:
            mp.datalist(2, 1, did);
            break;
        case 3:
            mp.datalist(3, 1, did);
            break;
        case 4:
            mp.datalist(4, 1, did);
            break;
        case 5:
            mp.datalist(5, 1, did);
            break;
        case 6:
            mp.datalist(6, 1, did);
            break;
        case 7:
            mp.datalist(7, 1, did);
            break;
        case 8:
            mp.datalist(8, 1, did);
            break;
        case 9:
            mp.datalist(9, 1, did);
            break;
        case 10:
            mp.datalist(10, 1, did);
            break;
         case 11:
            mp.datalist(11, 1, did);
            break;           
        }
        $(this).addClass("pton").siblings().removeClass("pton")
    })
}), jQuery, jQuery.cookie = function(e, a, i) {
    if (arguments.length > 1 && (null === a || "object" != typeof a)) {
        if (i = jQuery.extend({},
        i), null === a && (i.expires = -1), "number" == typeof i.expires) {
            var t = i.expires,
            n = i.expires = new Date;
            n.setDate(n.getDate() + t)
        }
        return document.cookie = [encodeURIComponent(e), "=", i.raw ? String(a) : encodeURIComponent(String(a)), i.expires ? "; expires=" + i.expires.toUTCString() : "", i.path ? "; path=" + i.path: "", i.domain ? "; domain=" + i.domain: "", i.secure ? "; secure": ""].join("")
    }
    var o, s = (i = a || {}).raw ?
    function(e) {
        return e
    }: decodeURIComponent;
    return (o = new RegExp("(?:^|; )" + encodeURIComponent(e) + "=([^;]*)").exec(document.cookie)) ? s(o[1]) : null
},
void 0 === window.FMP) var FMP = window.FMP = new
function() {
    var e = /msie/.test(navigator.userAgent.toLowerCase());
    function a(e, a) {
        if (a && "object" == typeof a) for (var i in a) e[i] = a[i];
        return e
    }
    this.get = function(a) {
        var i = document.getElementById(a);
        return i && "object" === i.nodeName.toLowerCase() || (i = e ? window[a] : document[a]),
        i
    },
    this.create = function(i, t, n, o, s, d, l) {
        o += "?" + Math.random();
        var r = {
            width: t,
            height: n,
            id: i
        };
        a(r, l);
        var c, p = {
            allowfullscreen: "true",
            allowscriptaccess: "always"
        };
        if (a(p, d), s) if ("object" == typeof s) {
            var m = [];
            for (var u in s) m.push(u + "=" + encodeURIComponent(s[u]));
            c = m.join("&")
        } else c = s + "";
        c && (p.flashvars = c);
        var f = "<object ";
        f += e ? 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" ': 'type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" data="' + o + '" ';
        for (var h in r) f += h + '="' + r[h] + '" ';
        f += e ? '><param name="movie" value="' + o + '" />': ">";
        for (var v in p) f += '<param name="' + v + '" value="' + p[v] + '" />';
        return f += '<param name="wmode" value="transparent" />',
        f += "</object>"
    }
};

function mpOnload() { (fmpObj = FMP.get("fmp")).doPlay(danceFilePath,djname),
    fmpObj.addBackground(danceBg)
}
var mp = {
    listenFlag: 1,
    isClose: 1,
    obj: "",
    danceList: "",
    $mpList: "",
    onload: function() {
        mp.obj = FMP.get("fmp"),
        mp.$mpList = parent.$("#mpList"),
        $(parent.document).bind("mousedown",
        function() {
            0 == mp.isClose && mp.$mpList.hide()
        }),
        $(document).bind("mousedown",
        function() {
            0 == mp.isClose && mp.$mpList.hide()
        }),
        mp.$mpList.mousedown(function(e) {
            e.stopPropagation()
        }),
        mp.$mpList.hover(function(e) {},
        function(e) {
            mp.$mpList.hide()
        })
    },
    listen: function() {
        "1" == $.cookie("openPlayer") ? ("" != mp.obj && mp.obj.doStop(), mp.listenFlag = 0) : setTimeout("mp.listen()", 2000)
    },
    playing: function(e, a) {
        0 == mp.listenFlag && ($.cookie("openPlayer", "", {
            path: "/",
            expires: 0,
            domain: baseDomain
        }), mp.listen())
    },
    home: function(e) {
        window.open("/", "_blank")
    },
    dance: function(e, a) {
        window.open("/dj/" + a + ".html", "_blank")
    },
    favorites: function(e, a) {
        web.ScAdd(a,0)
    },
    down: function(e, a) {
        download(a);
    },
    list: function(e) {
		if("" == mp.danceList){
			danceList = '<div class="mpListScroll"><ul>';
			for(var i=0; i<e.length; i++){
				danceList += '<li><a class="danceName" href="javascript:;" onClick="mpPlayer.play(' + i + ');mpPlayer.closeList();">' + (i + 1) + '. '+ e[i].danceName + '</a></li>';
			}
			danceList += "",
			mp.danceList = danceList;
			mp.isClose=0;
			mp.$mpList.html(mp.danceList).show();
		}else{
			mp.isClose=0;
			mp.$mpList.show();
		}
    },

    closeList: function() {
        mp.isClose = 1,
        mp.$mpList.hide()
    },
    Star: function() {
        $(window).bind("unload",
        function() {
            $.cookie("openPlayer", 0, {
                path: "/",
                domain: baseDomain
            })
        }),
        $.cookie("openPlayer", 1, {
            path: "/",
            domain: baseDomain
        }),
        mp.create("pFlash"),
        mp.Add_Dance(did),
        mp.Add_Dance(did, "history"),
        mp.datalist(0, 1)
    },
    Check_Flash: function() {
        if (navigator.mimeTypes.length > 0) try {
            navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
            return ! 0
        } catch(e) {
            return ! 1
        } else {
            if (!window.ActiveXObject) return ! 1;
            try {
                return new ActiveXObject("ShockwaveFlash.ShockwaveFlash"),
                !0
            } catch(e) {
                return ! 1
            }
        }
    },
    hasFlash: function(){
       if (navigator.plugins && navigator.plugins.length && navigator.plugins['Shockwave Flash']) {
            return true;
            } else if (navigator.mimeTypes && navigator.mimeTypes.length) {
            var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
            return mimeType && mimeType.enabledPlugin;
        } else {
            try {
                var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
                return true;
            } catch (e) {}
            }
        return false;
    },
    Check_Html5: function() {
        return "undefined" != typeof Worker
    },
    falshinstall: function() {
        window.open("http://www.adobe.com/go/getflash")
    },
    create: function(e) {
        if ("player" == e) {
                if (0 == mp.Check_Flash() || 0 == mp.hasFlash()) {
                    a = '<div style="background-color:#000000;line-height:40px;height:40px;text-align:center;color:red">您需要安装flash player 播放器插件才能正常试听！<span onclick="mp.falshinstall()" style="cursor:pointer;color:#ffcc00">去安装</span></div>'
                } else {
                    var a = FMP.create("fmp", "980", "64", "/res/home/mp/mplist_do.swf", {
                        playmode: 0
                    });
                }
            document.getElementById(e).innerHTML = a,
            mp.listen()
        } else {
            document.getElementById(e).innerHTML = '<audio src="" id="audio"></audio><div class="player-progress-bg" id="p-pb" onclick="click_progress()"><div class="player-progress" id="p-pg"></div><span class="player-bar" id="p-bar"></span></div><div class="player-more"><div class="player-btn"><a href="javascript:previouSong();" class="player-up"></a><a href="javascript:player_play()"class="player-play "id="p-play"></a><a href="javascript:nextSong();" class="player-down"></a><div class="control"><div class="volume"><div href="javascript:void(0);" onclick="muted(\'firefox\',this);" class="control mute icon" id="m-play"></div><div class="slider nen"><div class="volume_n"></div></div></div></div><div class="other"><span class="palyer-tips" id="p-tips">点击播放</span><span id="p-time1">00:00</span>&nbsp;/&nbsp;<span id="p-time2">00:00</span></div></div></div>',
            audio = document.getElementById("audio"),
            audio.loop = !1,
            audio.addEventListener("ended",
            function() {
                mpPlayEnd()
            }); 
        }
    },
    listplay: function(e) {
        var a = 0,
        i = 0,
        t = $.cookie("idc_Temporary");
        if (null != t && "" != t) for (var n = (t = t.split(",")).length - 1, o = 0; o < n; o++) t[o] == e && ((a = o + 1) >= n ? void 0 != t[0] && (i = t[0]) : void 0 != t[a] && (i = t[a]));
        0 == i && (i = e),
        location.href = "/" + durl + "/" + i + dhtml
    },
    Add: function(e) {
        1 != $.cookie("openPlayer") ? window.open("/" + durl + "/" + e + dhtml, "dj") : (mp.Add_Dance(e), Alertok("已添加到列表！",1))
    },
    AddL: function(e) {
        var a = "";
        if ($("input[name=id]:checked").each(function() {
            "" != $(this).val() && (a += $(this).val() + ",")
        }), "" != a) if (a = a.substr(0, a.length - 1), mp.Add_Dance(a), 1 != $.cookie("openPlayer")) {
            var i = new Array;
            i = a.split(","),
            window.open("/" + durl + "/" + i[0] + dhtml, "dj")
        } else Alertok("批量加入列表成功",1);
        else Alert("请选择要添加的舞曲！");
    },
    DownaddL: function(e) {
        var a = "";
        if ($("input[name=id]:checked").each(function() {
            "" != $(this).val() && (a += $(this).val() + ",")
        }),"" != a); 
        if (a = a.substr(0, a.length - 1)) {
            var i = new Array;
            i = a.split(",");
            window.open("/pldown?id="+i, "dj");
        }else{
            Alert("请选择要下载的舞曲！");
        }
    },
    Add_Dance: function(e, a) {
        if (e += "", "history" == a) var i = $.cookie("idc_history");
        else i = $.cookie("idc_Temporary");
        var t = new Array,
        n = "",
        o = "",
        s = "";
        if (null != i && "" != i) {
            i = i.split(","),
            t = e.split(",");
            for (var d = i.length - 1,
            l = 0; l < d; l++) {
                var r = $.inArray(i[l], t);
                r >= 0 ? (s += i[l] + ",", delete t[r]) : s += i[l] + ","
            }
            for (index in t) o += t[index] + ",";
            n = s + o
        } else {
            t = e.split(",");
            for (index in t) n += t[index] + ","
        }
        "history" == a ? $.cookie("idc_history", n, {
            path: "/",
            expires: 86400,
            domain: baseDomain
        }) : $.cookie("idc_Temporary", n, {
            path: "/",
            expires: 86400,
            domain: baseDomain
        })
    },
    deldata: function(e, a) {
        if ("history" == a) var i = $.cookie("idc_history");
        else i = $.cookie("idc_Temporary");
        if (null != i && "" != i) {
            var t = i.split(","),
            n = t.length - 1;
            i = "";
            for (var o = 0; o < n; o++) t[o] != e && "" != t[o] && (i += t[o] + ",");
            "history" == a ? ($.cookie("idc_history", i, {
                path: "/",
                expires: 86400,
                domain: baseDomain
            }), mp.datalist(1, 1)) : ($.cookie("idc_Temporary", i, {
                path: "/",
                expires: 86400,
                domain: baseDomain
            }), mp.datalist(0, 1))
            //Alertok("成功删除本首！",1)
        }
    },
    pldeldatab: function(e, a) {
        var ids = $('input[name=id]:checked');
        var value = new Array();
        for(var i = 0; i < ids.length; i++){
                 if(ids[i].checked)
                 value.push(ids[i].value);  
        } 
        var num = i;
        var data = value.toString();
        if(data!=0){
           var msg = Alertok("删除成功！",1);
        }else{
           var msg = Alert("请先选择舞曲！");
        }
        if ("history" == a) var i = $.cookie("idc_history");
        else i = $.cookie("idc_Temporary");
        if (null != i && "" != i) {
            var t = i.split(","),
            n = t.length - num;
            i = "";
            for (var o = 0; o < n; o++) t[o] != data   && "" != t[o]   && (i += t[o] + ",");
              "history" == a ? ($.cookie("idc_history", i, {
                path: "/",
                expires: 86400,
                domain: baseDomain
            }), mp.datalist(1, 1)) : ($.cookie("idc_Temporary", i, {
                path: "/",
                expires: 86400,
                domain: baseDomain
            }), mp.datalist(0, 1)),
             msg
        }
    },
    pldeldata: function(e, a) {
       $.cookie("idc_Temporary", 0, {path: "/",expires: 86400,domain: baseDomain}),mp.datalist(0, 1)
       Alertok("全部清空成功！",1);
       
    },
    datalist: function(e, a, i) {
        if(e==0){
            $('.caozuo .xuan_del').show();
        }else{
            $('.caozuo .xuan_del').hide();
        }
        a = parseInt(a),
        e = parseInt(e),
        $("#sort").html("<script>layer.load(2);setTimeout(function(){layer.closeAll('loading');},1);</script>");
        var t = "";
        0 == e ? i = $.cookie("idc_Temporary") : 1 == e && (i = $.cookie("idc_history")),
        $.ajax({
            type: "POST",
            url: "/ajax/lists",
            data: "sid=" + e + "&page=" + a + "&dids=" + i,
            dataType: "json",
            success: function(n) {
                if ("login" == n.error && (t = "<br><div align='center'>您没有登录，请登录后查看</div><br>", user.userNotLogin('您需要先登录会员账户!')), "no" == n.error && (t = "<br><div align='center' class=bai>暂时没有记录</div><br>"), "ok" == n.error) {
                    var o;
                    if (t += '', void 0 != n.arr) for (var s in n.arr)(o = parseInt(s) + parseInt(1)) < 10 && (o = "0" + o),
                    did == n.arr[s].did ? 
                    t += '<ul class="ok" style="border-top:0;" data="ok"><div class="num"><input class="selmusic" type="checkbox" name="id" value="' + n.arr[s].did + '"/></div><div class="bt"><a class="cur" href="' + n.arr[s].did + '.html" target="dj">': 
                    t += '<ul class="td" style="border-top:0;" data="td"><div class="num"><input class="selmusic" type="checkbox" name="id" value="' + n.arr[s].did + '"/></div><div class="bt"><a class="cur" href="' + n.arr[s].did + '.html" target="dj">',
                    t += '' + n.arr[s].dance_name + "</a></div>",
                    t += 0 == e ? '<div class="icodel"><a href="javascript:void(0)" onclick="mp.deldata(' + n.arr[s].did + ');"></a></div></ul>':  1 == e ? '<div class="icoadd"><a href="javascript:void(0)" onclick="mp.Add(' + n.arr[s].did + ');"></a></div></ul>': '<div class="icoadd"><a href="javascript:void(0)" onclick="mp.Add(' + n.arr[s].did + ');"></a></div></ul>';
                    t += "",
                    n.total > 1 && (upPage = a - 1 < 0 ? 1 : a - 1, a + 1 < n.total ? nextPage = a + 1 : nextPage = n.total, 0 != e && 1 != e || (i = ""), 
                        t += "<div class='fenye'>", upPage <= 0 ? t += "<a onclick=\"Alert('当前是第一页！');\" href=\"javascript:;\">上一页</a>": 
                        t += "<a onclick=\"mp.datalist('" + e + "' ,  '" + upPage + "', '" + i + '\');" href="javascript:;">上一页</a>', 
                        t += "<a>第" + a + "页 / 共" + n.total + "页</a>", a == n.total ? t += "<a onclick=\"Alert('当前是最后一页！');\" href=\"javascript:;\">下一页</a>": 
                        t += "<a onclick=\"mp.datalist('" + e + "' ,  '" + nextPage + "', '" + i + '\');" href="javascript:;">下一页</a>', 
                        t += "</div>")
                }
                $("#sort").html(t)
            }
        })
    }
},


web = {
    Goods: function(e, a) {
        $.getJSON("/ajax/good?", {
            did: escape(e),
            uid: escape(a),
            rand: Math.random()
        },
        function(e) {
            if ("66dj" != e.error) {
                var a = e.error.split("_");
                $("#good_times").html(a[0]),
                $("#bad_times").html(a[1])
              Alertok("谢谢您的支持!",1)
            } else Alertok("24小时内已顶(踩)过此舞曲",1)
        })
    },
    ScAdd: function(e, a) {
          CheckLogin_Exc( FAV.SelFav(e) );
    },
    down: function(e) {
        window.open("/" + durl + "/down" + e + dhtml, "x")
    }
};
function addToFavorite() {
    web.ScAdd(did, 0)
}
function downloadSong() {
    download(did);
}
function previouSong() {
    //location.href = "/" + durl + "/" + last + dhtml
    mp.listplay(did)
}
function nextSong() {
    //location.href = "/" + durl + "/" + next + dhtml
     mp.listplay(did)
}
function mpPlayEnd() {
    mp.listplay(did)
}
var mpPlayer = {
    play: function(e) {
        document.getElementById("player"),
        (fmpObj = FMP.get("fmp")).doPlay(e)
    },
    closeList: function() {
        mp.closeList()
    }
};

function Xuana(a) {
    var e = $('#'+a+' input');
    if (0 == e.length) Alert("你想全选啥?");
    else for (var a in e) e[a].checked = (e[a].checked, "checked")
}

function Xuanb(a){
        var e = $('#'+a+' input');
        if (0 == e.length) Alert("你想反选啥?");
        else for (var a in e) e[a].checked = e[a].checked ? "": "checked"
}

function tab(id,index){
	var last = index == 1 ? 2 : 1;
	$('#tab_'+id+'_'+last).removeClass("cur");
	$('#tab_'+id+'_'+index).addClass("cur");
	$('#tab_'+id+'_'+index).parent().siblings().html($('#tab_'+id+'_'+index).html()+$('#tab_'+id+'_'+index).parent().siblings().html().substr(2));
	$('#ul_'+id+'_'+last).addClass("none");
	$('#ul_'+id+'_'+index).removeClass("none");
	$('#btn_'+id+'_'+last).addClass("none");
	$('#btn_'+id+'_'+index).removeClass("none");
}


function nTabs(thisObj,Num){
	if(thisObj.className == "cur")return;
	var tabObj = thisObj.parentNode.id;
	var tabList = document.getElementById(tabObj).getElementsByTagName("a");
	for(i=0; i <tabList.length; i++){
	  if (i == Num){
	   thisObj.className = "cur"; 
	      document.getElementById(tabObj+"_Content"+i).style.display = "block";
	  }else{
	   tabList[i].className = "on"; 
	   document.getElementById(tabObj+"_Content"+i).style.display = "none";
	  }
	} 
}


var PubLay = {
    name: "",
    close: function () {
        layer.close(this.name);
    }
}

var user = {
    //用户未登录
    userNotLogin: function(msg){
          Alertok(msg ,0 ,function(){
              libs.login();
          });
    },
    //检测用户是否登录
    loginInit: function(tid){
        var $url = $("#refer").val();
        var $loginName = $("#loginName");
        var $password = $("#password");
        var $setCookieTime = $('#setCookieTime');
        var $errMessage = $('#errMessage');
        $("#submit2").click(function(){
            if($loginName.val()=='' || $loginName.val()=='登陆账号'){
                $errMessage.html('请输入正确的账号！').show();
                $loginName.val('').focus();
                return false;
            }else if($loginName.val().length<3){
                $errMessage.html('账号长度应大于4位！').show();
                $loginName.focus();
                return false;
            }else if($password.val()==''){
                $errMessage.html('登陆密码不能为空！').show();
                $password.val('').focus();
                return false;
            }else if($password.val().length<6){
                $errMessage.html('密码长度应大于6位！').show();
                $password.focus();
                return false;
            }
            $errMessage.html('登录中，请稍后...').show();
            if($setCookieTime.is(":checked")){
                cookieTime = 1;
            }else{
                cookieTime = 0;
            }
            $.get("/user/ulog/login?cooktime="+cookieTime+"&username="+escape($loginName.val())+"&userpass="+escape($password.val()),function(data) {
                                if(data=='40000'){
                                    $errMessage.html('系统维护,暂时无法登录!').show();
                                } else if(data=='10001'){ 
                                     $errMessage.html('帐号不能为空!').show();
                                } else if(data=='10002'){ 
                                     $errMessage.html('密码不能为空!').show();
                                } else if(data=='10004'){
                                     $errMessage.html('用户名格式不正确!').show();
                                } else if(data=='10005'){ 
                                     $errMessage.html('帐号不存在!').show();
                                } else if(data=='10006'){ 
                                     $errMessage.html('密码错误!').show();
                                } else if(data=='10007'){ 
                                     $errMessage.html('抱歉，您的帐号存在违规已被冻结!').show();
                                } else if(data=='10008'){ 
                                      Alertok('为了更好的体验，请您先完善头像!',0 , function(){location.href = "/user/edit/logo.html";})
                                } else if(data=='10009'){
                                      Alertok('登陆成功正在跳转...',1)
                    if(tid!=undefined){
                        if( $url!=undefined){
                            location.href = $url;
                        }
                        else{
                            location.href = '/user/home.html';
                        }
                    }else{
                        libs.checkLogin();
                        var dialogObj = typeof(login);
                        if(dialogObj == 'object'){
                           PubLay.close();
                        }
                     }
                   if(location.href.indexOf('down')>-1){
                        location.href = location.href;
                   }

                }else{ 
                    Alert(data);
                }

            });
            return false;
        });
    }
};


//管理
var libs = {
    //检测是否登录
    checkLogin: function(){
        var $Login = $("#dj63_login");
        var $userLogin = $("#userLogin");
        var $userInfo = $("#userInfo");
        var $welcome = $("#welcome");
        var $siteLink = $("#siteLink"); 
                $.get("/user/ulog?random="+Math.random(),function(data) {
                if(data!='no'){
                $welcome.hide();
                $userLogin.html(data);
                $Login;
                }
            });
        return false;
    },
    //退出登录
    logout: function(){
        var $userLogin = $("#userLogin");
        var $welcome = $("#welcome");
            $.get("/user/ulog/logout?random="+Math.random(),function(data) {
                if(data){
                $welcome.show();
                $userLogin.hide();
                 Alertok('恭喜已安全退出...',1);
                 location.reload(); 
                }else{
                 Alert("网络连接失败！");
                }
            });
        return false;
    },
    //个人页面
    home: function(){
            $.get("/user/ulog/home?random="+Math.random(),function(data) {
                if(data==10001){
                  Alert("请完善头像和昵称！");
                }else{
                  location.href = '/i/'+data+'.html';
                }

            });
        return false;
    },
    //空间登录框     
    login: function(){
        var loghtml='<div class="user_dialog_login"><div class="left"><div class="left_line"><div class="message"><span id="errMessage"></span></div></div><div class="left_line"><div class="dl_loginName"><input type="text" name="loginName" id="loginName" class="input_normal" placeholder="账号 / 手机" maxlength="70" autocomplete="off"></div></div><div class="left_line"><div class="dl_password"><input type="password" name="password" id="password" class="input_normal" placeholder="登录密码" maxlength="30" autocomplete="off"></div></div><div class="left_line"><div class="right"><a href="/user/pass.html" target="_blank">忘记密码?</a></div><label><input id="setCookieTime" class="check_box" type="checkbox" name="setCookieTime">下次自动登录</label></div><div class="style"><input class="home_btn" type="submit" id="submit2" value="登 陆"></div></div><div class="right_line"><div class="title">还未开通？</div><div class="reg"><a class="home_btn" href="/user/reg.html" target="_blank"></a></div><div class="partner"><p class="tit">或使用合作网站账号登陆</p><div class="qq"><a href="javascript:libs.wqlog(\'qq\');"> <img src="/res/home/images/qqconnect.gif"></a></div><div class="qq"><a href="javascript:libs.wxlog(\'wx\');"><img src="/res/home/images/wxconnect.gif"></a></div></div></div></div>';
        PubLay.name = layer.open({
          id: 'login',
          title: '会员登录',
          type: 1,
          skin: 'layui-layer-rim',
          area: ['570px', '270px'], 
          content: loghtml
        });
        user.loginInit();
        return false;
    },
    wqlog: function(ac){
        layer.open({
          id: 'qqlogin',
          title: 'QQ登陆',
          type: 2,
          skin: 'layui-layer-rim',
          area: ['720px', '630px'], 
          content: '/index.php/open/login/'+ac
        });
        var dialogObj = typeof(login);
        if(dialogObj == 'object'){
          PubLay.close();
        }
    },
    wxlog9: function(ac){
        layer.open({
          id: 'wxlogin',
          title: '微信登录',
          type: 2,
          skin: 'layui-layer-rim',
          area: ['380px', '380px'], 
          content: '/index.php/wxapi/login'
        });
        var dialogObj = typeof(login);
        if(dialogObj == 'object'){
          PubLay.close();
        }
    },
    wxlog: function (ac) {
        var url = '/index.php/open/login/' + ac;    //转向网页的地址;
        var name = '第三方登录';                     //网页名称，可为空;
        var iWidth = 500;                            //弹出窗口的宽度;
        var iHeight = 500;                           //弹出窗口的高度;
        //获得窗口的垂直位置
        var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
        //获得窗口的水平位置
        var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
        //window.open(url, name);
        window.open(url, name, 'height=' + iHeight + ',,innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no');
        PubLay.close();
    }
};

function qqclose(){  
        $(function(){  
            parent.location.reload();
            parent.layer.closeAll();
        });
} 

//错误
function Alert(curct) {
    curct = "<span style='color:#d7880c;font-size:14px;'>" + curct + "</span>";
    layer.msg(curct, {time: 2000, shade:0.3, icon: 0});
    return false;
}

//提示
function Alertno(curct) {
    curct = "<span style='color:#d7880c;font-size:14px;'>" + curct + "</span>";
    layer.alert(curct, {time: 2000, shade:0.3, icon: 0});
    return false;
}

//正确
function Alertok(curct, num , op) {
    if (num == 0) {
        curct = "<span style='color:#d7880c;font-size:14px;'>" + curct + "</span>";
    } else {
        curct = "<span style='color:#03947c;font-size:14px;'>" + curct + "</span>";
    }
    layer.msg(curct, {time: 1000, shade:0.3, icon: num} ,op);
    return false;
}

function trim(str){   
    str = str.replace(/^(\s|\u00A0)+/,'');   
    for(var i=str.length-1; i>=0; i--){   
        if(/\S/.test(str.charAt(i))){   
            str = str.substring(0, i+1);   
            break;   
        }   
    }   
    return str;   
}  

var dj63={
     tmpsel:0,
     banner:function(){
        $("#selbox2").toggle(
          function () { $(".selboxct").show();$("#selbox>ul").attr("class","seldown"); },
          function () { $(".selboxct").hide();$("#selbox>ul").attr("class","selup"); } );
        $(".asel").click(function(){
           var tvalue=$(this).attr("ids");
           arr=tvalue.split("-");
           $("#lx").val(arr[0]);$("#selbox>ul").html(arr[1]);
        });
        $(".se").hover(function() {$(this).find("ul:first-child").stop().attr("class","banneron");$(this).find("div:first").stop().show()
        },function() { $(this).find("ul:first-child").stop().attr("class","se banneroff");$(this).find("div:first").stop().hide()});

        $("#searchbt").click(function(){
           var tmpkeys=trim($("#key").val());
           if (tmpkeys.length<1){
               Alert("选择搜索分类后，必须输入关键词...");
               return;
               }
           var classid=$("#lx").val();

           var objform=document.getElementById("search")
           switch (parseInt(classid)) {
               case 1:
                  objform.action="/search";break;
               case 2:
                  objform.action="/search/taoqu";break;
            } 
            document.getElementById("search").submit();
         });
         $("#key").keyup(function(){
            if  (parseInt($("#lx").val())==1){              
                 newserkeys=$(this).val();
            }
         });
         $("#inputbox").hover(function(){
            var thtml= $("#ser_result").html()
            if (thtml!=""){$("#ser_result").show();}
         },
      function(){$("#ser_result").hide();})
         $("#myrmb").hover(function(){$(".icohistory").attr("class","icohistoryon");$("#serlist").stop().show();},function(){$(".icohistoryon").attr("class","icohistory");$("#serlist").stop().hide();}); 
         $("#addsc").hover(function(){$(".icojrsc").attr("class","icojrscon");$("#sclist").stop().show();},function(){$(".icojrscon").attr("class","icojrsc");$("#sclist").stop().hide();});
         $("#mycjwt").hover(function(){$(".icocjwt").attr("class","icocjwton");$("#serlist").stop().show();},function(){$(".icocjwton").attr("class","icocjwt");$("#serlist").stop().hide();}); 
         $("#mybook").hover(function(){$(".icotsjy").attr("class","icotsjyon");$("#serlist").stop().show();},function(){$(".icotsjyon").attr("class","icotsjy");$("#serlist").stop().hide();}); 
     }
}

var Xkey=$("#key").val();
var SERSHOW=0;
var MySearch = {
    oldkey:Xkey,
    trim:function(str) {
        return str.replace(/(^\s*)|(\s*$)/g, "");
    },
    selval:function(datas) {
        $("#ser_result").hide();
        $("#key").val(datas);
        $("#search").submit();
    },
    replaces: function (findstr, strs) {
        if (strs.length > 0) {
            return strs.replace(findstr, '<span>' + findstr + '</span>');
        }
    },
    getlist:function() {
        var newkey = this.trim($("#key").val());
        var keyid = this.trim($("#lx").val());
        if (this.oldkey != newkey && newkey.length > 0) {
            if(keyid == 1){
                keyurl = "/search/sodj.html?query=";
                keygo = "/search?key=";
            }else{
                keyurl = "/search/sozj.html?query=";
                keygo = "/search/taoqu?key=";
            }
            $.ajax({
                url: keyurl + newkey,
                xhrFields:{
                    withCredentials:true
                },
                dataType:"json",
                success:function(data) {
                    if (data.status === "OK" && data.result) {
                        var html = "";
                        var counts = data.result.length;
                        if (counts > 0) {
                            html+="<ul>";
                            for (i = 0; i < counts; i++) {
                                html += "<a href=\""+ keygo + data.result[i] + "\" class=\"sersel\">" + MySearch.replaces(newkey, data.result[i]) + "</a>";
                            }
                            html += "</ul>";
                            $("#ser_result").html(html);
                            if (SERSHOW==0){
                                 $("#ser_result").show();
                            }
                        } else {
                            $("#ser_result").html("");
                            $("#ser_result").hide();
                        }
                    } else if (data.status === "FAIL" && data.errors) {
                        $("#ser_result").hide();
                    }
                }
            });
            this.oldkey = newkey;
        } else if (newkey.length == 0) {
            $("#ser_result").html("");
            $("#ser_result").hide();
        }
    }
};
/* setInterval("MySearch.getlist()", 2000); */


function DjFav(id){
  CheckLogin_Exc(FAV.SelFav(id));
}

function download(musicid){
        layer.open({
          id: 'download',
          title: '舞曲下载',
          type: 2,
          skin: 'layui-layer-rim',
          area: ['980px', '690px'], 
          content: '/down/'+musicid+'.html?fid=1'
        });
}